package com.example;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.*;

@WebServlet("/student")
public class StudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Student> studentList = Arrays.asList(
                new Student(1001, "zhangsan"),
                new Student(1002, "lisi"),
                new Student(1003, "wangwu"),
                new Student(1004, "zhaoliu"),
                new Student(1005, "雷军")

        );

        req.setAttribute("students", studentList);

        req.getRequestDispatcher("/student.jsp").forward(req, resp);
    }



}
